class Solution {
    public int findSubstringInWraproundString(String s) {
             int len = s.length() ;
             int[] dp = new int[len] ; 
             dp[0] = 1 ;
             for(int i=1 ; i < len ; i ++){
               char a =  s.charAt(i) , b = s.charAt(i-1);
              dp[i] = 1 ;
              if(a-b == 1 ||  a=='a' && b=='z' ){
              dp[i] += dp[i-1] ;
              }
             }
            int [] arr = new int[26] ;
            for(int i=0 ; i< len ; i++){
                char ch =s.charAt(i) ; 
                arr[ch-'a'] = Math.max(arr[ch-'a'] , dp[i]);
            }
        int sum = 0 ; 
        for(int num : arr){
            sum += num ;
        }
       return sum ;
    }
}